#ifndef _APP_H
#define _APP_H

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <Box2D\Box2D.h>
#include <iostream>

#include "movie_player.h"
#include "script_engine.h"
#include "text.h"


extern int CallScriptFunction(asIScriptContext * Context, std::string funcName);



/* Main Application Class */
class App
{
	public:
		
		//singleton stuff
		static App &getInstance();


		

		//Main Functions for handling the App
		bool Init();
		bool Main_Loop();
		void Destroy();


		void Draw_Scene();
/*
		//Setters/Getters for Window Size
		sf::Vector2i Get_WindowSize();
		void Set_WindowSize(int w_width, int w_height);
		void Set_WindowSize(sf::Vector2i new_size);
*/

	    //Get Render Windowz!!!
		sf::RenderWindow* Get_RenderWindow();
		void Set_RenderWindow(sf::RenderWindow& Ren);
		

		//Get position of mouse, 
		sf::Vector2f Get_MousePosition() { return mouse_pos; }


		//Get ScreenSize
		sf::Vector2i Get_ScreenSize() { return screen_size; }


		std::map<std::string, std::string> Resources_Dir;

		//Music
		//since their is only one song playing at a time,
		//im ok with this being here...for now.
		sf::Music Music;

		sf::Vector2f GetMouse() { return mouse_pos; }


		sf::Vector2f GetGameViewCoords(sf::Vector2f &pos)
		{
			return sf::Vector2f(Rendow->ConvertCoords(pos.x, pos.y, gameView));
		}



	protected:

		//Singleton stuff
		static App _instance;

		App();
		App(const App &);
		App & operator=(const App &);


		//wegistur wif teh swipt engine
	    bool Register_With_ScriptEngine();

		//Get Average Framerate
		int GetAverageFPS( float );


		//Render Window reference
		sf::RenderWindow *Rendow;


		//Drawing Views
		sf::View gameView;
		sf::View menuView;

		//Gobal version of the game Delta-time
		float delta_time;


		/* Window Properties */
		int color_depth;
		int screen_style;

		std::string title, version;

		sf::Vector2i screen_size;

		//mouse position
		sf::Vector2f mouse_pos;
		b2Vec2 screen_mouse;

		//main scripting context
		asIScriptContext * ctxMain;





		sf::Shape test_rec, unbuildable[4];



		//Fonts
		sf::Font InfectedFont, DoomFont;

		//Create Texts' to the screen
		 Text FrameRate;	
};


#endif